<template>
	<view class="wrapper">
		<view class="tx_num cfff">提币金额</view>
		<view class="inp_num">
			<text class="cfff">USDT</text>
			<input type="text" style="color: #fff;" v-model="money" class="number flex" placeholder="请输入提币数量"/>
		</view>
		<view class="inp_num">
			<text class="cfff">提币地址</text>
			<input type="text" style="color: #fff;" v-model="toAddress" class="number flex"  placeholder="请输入提币地址"/>
		</view>
		<view class="total_box">
			<view class="total cfff">可用：</view>
			<text class="total_num cfff">
				{{ balance | toTwo(4) }}
				<text class="cfff">  USDT</text>
			</text>
		</view>
		<button type="default" class="wpay wadh" @tap="alertConfirm">确定</button>
		<view class="alert_title cfff f30 alert">
			提现须知：
		</view>
		<view class="alert_text alert">
			1：最小提币数量为 100 USDT；
		</view>
	
		<view class="alert_text alert">
			2：每次提币手续费扣除 10 USDT。
		</view>
		<alert :alertTitle="'请输入支付密码'" :showInput="true" v-if="showPay" @alertConfirm="alertConfirm"></alert>
	</view>
</template>

<script>
import md5 from '@/common/md5.min.js';
import alert from '@/components/alert/alert.vue';
export default {
	data() {
		return {
			balance: 0,
			money: '', //提现金额
			showPay: false,
			toAddress:'' //收款钱包地址
		};
	},
	onLoad(e) {
		if(e.balance>0){
			this.balance = e.balance;
		}
	},
	onNavigationBarButtonTap(){
			window.location.reload()
		},
	methods: {
		alertConfirm(type, payPassword) {
			if (this.money < 100) {
				this.$sToast('提币金额最低为100');
				this.showPay = false;
				return;
			}
			if (this.toAddress=='') {
				this.$sToast('提币地址不能为空');
				this.showPay = false;
				return;
			}
			if (type == 1) {
				this.transToWallet(payPassword) 
			}
			this.$ajax(
				'bi/getCheckUsdt',
				{
					money: this.money,
					userId:uni.getStorageSync('userinfo').userId,
					address:this.toAddress
				},
				'POST'
			).then(res => {
				this.$sToast('提币申请成功');
				this.$back(1, 1500);
			});
		},
		transToWallet(payPassword) {
			// let time = parseInt(new Date().getTime() / 1000),
			// 	userid = uni.getStorageSync('userinfo').userId,
			// 	token = uni.getStorageSync('userinfo').access_token;
			// this.$ajax(
			// 	'bi/getCheckUsdt',
			// 	{
			// 		money: this.money,
			// 		userId:uni.getStorageSync('userinfo').userId,
			// 		address:this.toAddress
			// 	},
			// 	'POST'
			// ).then(res => {
			// 	this.$sToast('提币申请成功');
			// 	this.$back(1, 1500);
			// });
		}
	}
}
</script>

<style lang="scss">
	page {
		background-color: #0E1B45;
	}
.alert_text{
		color:#FFA61E ;
	}
	.alert{
		padding: 6rpx 50rpx;
	}
	.alert_title{
		font-weight: bold;
		padding: 30rpx 50rpx 30rpx;
	}
.wrapper {
	background: #0E1B45;
	display: flex;
	flex-direction: column;
}

.tx_num {
	font-size: 26rpx;
	font-weight: 500;
	color: rgba(102, 102, 102, 1);
	margin: 31rpx 0 20rpx 30rpx;
}

.inp_num {
	height: 104rpx;
	background-color: #0E1B45;
	display: flex;
	flex-direction: row;
	align-items: center;
	border-bottom: 1rpx solid rgba(224, 224, 224, 1);
}

.inp_num text {
	font-size: 30rpx;
	font-weight: 500;
	color: rgba(51, 51, 51, 1);
	margin-left: 30rpx;
	margin-right: 10rpx;
	width: 150rpx;
}

.total_box {
	display: flex;
	flex-direction: row;
	align-items: center;
	margin: 30rpx 20rpx 27rpx 30rpx;
}

.total_box .total {
	font-size: 26rpx;
	font-weight: 500;
	color: rgba(102, 102, 102, 1);
	margin-right: 20rpx;
}

.total_num {
	font-size: 30rpx;
	font-weight: 500;
	color: rgba(51, 51, 51, 1);
	text{
		padding-left: 20rpx;
	}
}

.wadh {
	width: 690rpx;
	height: 80rpx;
	background: rgba(2, 151, 254, 1);
	border-radius: 8rpx;
	font-size: 30rpx;
	font-weight: 500;
	color: rgba(255, 255, 255, 1);
	margin-left: 30rpx;
}
.wpay {
	margin-bottom: 20rpx;
	background-color: #00B34D;
}
.tips {
	font-size: 26rpx;

	font-weight: 500;
	color: rgba(102, 102, 102, 1);
	margin: 29rpx 0 0 30rpx;
}
</style>
